6-消息确认 ACK

接收到客户端的ACK响应

1
2
//ConnectionServer#init()
messageDispatcher.register(Command.ACK, () -> new AckHandler(mPushServer));

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
public final class AckHandler extends BaseMessageHandler<AckMessage> {
private final AckTaskQueue ackTaskQueue;
public AckHandler(MPushServer mPushServer) {
this.ackTaskQueue = mPushServer.getPushCenter().getAckTaskQueue();
}
@Override
public AckMessage decode(Packet packet, Connection connection) {
return new AckMessage(packet, connection);
}
@Override
public void handle(AckMessage message) {
AckTask task = ackTaskQueue.getAndRemove(message.getSessionId());
if (task == null) {//ack 超时了
Logs.PUSH.info("receive client ack, but task timeout message={}", message);
return;
}
task.onResponse();//成功收到客户的ACK响应
}
}



接入服务文章目录:

------ 本文结束 感谢您的阅读 ------